#ifndef _CALC_ITEM_H_
#define _CALC_ITEM_H_

#define IN 
#define OUT 
#define INOUT
#define DBGASSERT(x) 
#define ERR_SUCCESS (0)
#define ERR_FAILED  (-1)

#define CALC_ITEM_DATA_TYPE double
#define CALC_ITEM_TYPE_OP   (0)
#define CALC_ITEM_TYPE_DATA  (1)
/* the value in the item can have 16 byte space at most */
#define CALC_ITEM_VALUE_SIZE (16)

typedef struct tagCalcItem {
  unsigned int uiType;
  unsigned char aucValue[CALC_ITEM_VALUE_SIZE];
}CALC_ITEM_S;

#define CALC_ITEM_SET_VALUE(Item, Type, Value) \
do{\
  (Item).uiType = (Type);\
  switch (Type) {\
    case CALC_ITEM_TYPE_OP: {\
      *((char *)((Item).aucValue)) = (char)(Value);\
      break;\
    }\
    case CALC_ITEM_TYPE_DATA: {\
      *((CALC_ITEM_DATA_TYPE *)((Item).aucValue)) = (CALC_ITEM_DATA_TYPE)(Value);\
      break;\
    }\
    default:\
      break;\
  }\
}while (0)

#define CALC_ITEM_GET_VALUE(Item, Type, Value) \
do{\
  (Item).uiType = (Type);\
  switch (Type) {\
    case CALC_ITEM_TYPE_OP: {\
      (Value) = (char)((Item).aucValue[0]);\
      break;\
    }\
    case CALC_ITEM_TYPE_DATA: {\
      (Value) = *((CALC_ITEM_DATA_TYPE *)((Item).aucValue));\
      break;\
    }\
    default:\
      break;\
  }\
}while (0)

#endif
